#ifndef DW_SYSTEM_PROFILE_H
#	define DW_SYSTEM_PROFILE_H

namespace dw {
	namespace system {

class Profiler;

class Profile
{
public : //! @name Types definitions
	//! @{
	class Sample
	{
	public :  //! @name Construction & destruction
		//! @{
		inline Sample(const std::string&);
		~Sample();
		//! @}
	
	private: //! @name Data
		//! @{
		std::string _name;
		//! @}
	};
	//! @}

public : //! @name Construction & destruction
	//! @{
	inline Profile(const std::string&);
	inline ~Profile();
	//! @}

public: //! @name Commands
	//! @{
	inline void Dump(std::ostream&) const ;
	//! @}

public: //! @name State
	//! @{
	const std::string& Name() const { return _name; }
	const unsigned NumCall() const { return _numCall; }
	const double CurrentTime() const { return _currentTime; }
	const double TotalTime() const { return _totalTime; }
	const double MaxTime() const { return _maxTime; }
	const double MinTime() const { return _minTime; }
	const double AvgTime() const { return _totalTime / _numCall; }
	//! @}
	
private : //! @name Data
	//! @{
	std::string _name;
	unsigned _numCall;
	double _startTime;
	double _currentTime;
	double _totalTime;
	double _maxTime;
	double _minTime;
	//! @}

protected : //! @name Friends
	//! @{
	friend class Profiler;
	//! @}

};

	} // namespace system
} // namespace dw

#include "system/profile.inl"

# ifdef DW_COMPILER_DEBUG
#		define dwProfile(name) dw::system::Profile::Sample sample(name)
#	else
#		define dwProfile(name) (void)name
# endif

#endif // !DW_SYSTEM_PROFILE_H
